package com.jy.api.domain;

import com.jy.api.enums.OrderPayChannel;
import com.jy.api.signUpReq.MarsCallReq.RewardOrderReq;
import com.jy.api.util.Md5Util;
import com.jy.api.util.UuidUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by xiaohua on 2018/11/12.
 */
@Entity
@Data
@NoArgsConstructor
public class Reward {

    @Id
    @Column(length = 50)
    private String id;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date addTime;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    private String code;

    private int count;

    private String empId;

    private String empName;

    private boolean enabled = true;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    private String memberId;

    private String memberName;

    @Enumerated(EnumType.STRING)
    private OrderStatus status;

    @Enumerated(EnumType.STRING)
    private OrderPayChannel payChannel;
    private String storeId;

    private double total;

    private double commission;

    private String channel;

    private double companyAmount;

    private String tableNo;

    private String productId;

    private String productName;

    private String productImageurl;

    private Date paymentTime;


    public Reward(RewardOrderReq req, String empName, String productName, String productImageurl) {
        this.id = UuidUtil.getUuid();
        this.code = UuidUtil.getUuid();
        this.count = req.getCount();
        this.empId = req.getEmpId();
        this.empName = empName;
        this.enabled = true;
        this.status = OrderStatus.INIT;
        this.storeId = req.getStoreId();
        this.total = req.getTotal();
        this.tableNo = req.getTableNo();
        this.productId = req.getProductId();
        this.productName = productName;
        this.productImageurl = productImageurl;
    }
}
